package com.xiaochong.tir.manager.controller;

import com.github.pagehelper.PageInfo;
import com.xiaochong.tir.common.data.po.OperationLog;
import com.xiaochong.tir.manager.service.OperationLogService;
import com.xiaochong.tir.manager.util.ManagerVersion;
import com.xiaochong.tir.manager.util.ReturnResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by admin on 2018/6/1.
 */
@Controller
@RequestMapping(ManagerVersion.API_V1_PREFIX + "journal/")
@Api("操作日志管理")
public class OperationLogController {

    @Autowired
    private OperationLogService operationLogService;

    /**
     * 操作日志页面
     * @return
     */
    @GetMapping("handlepage")
    public String handlePage(){
        return "/operation/handlepage";
    }

    /**
     * 日志列表
     * @param operationLog
     * @param pageindex
     * @param pagesize
     * @return
     */
    @ApiOperation(value = "查询操作日志列表",notes = "查询操作日志列表")
    @PostMapping("operationlist")
    @ResponseBody
    public ReturnResult<OperationLog> selOperationList(OperationLog operationLog,
                                                       @RequestParam("page")Integer pageindex,
                                                       @RequestParam("limit") Integer pagesize){

        PageInfo<OperationLog> list = operationLogService.selectByOperaList(operationLog,pageindex,pagesize);
        ReturnResult<OperationLog> result = new ReturnResult<OperationLog>(0,"成功",list.getList(),list.getTotal());
        return result;
    }
}
